package cn.xuewenbao.edu.controller;


import cn.xuewenbao.edu.entity.vo.MyLikedVo;
import cn.xuewenbao.edu.service.LikeContentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 点赞表 前端控制器
 * </p>
 *
 * @author mafayu
 * @since 2021-04-21
 */
@RestController
@RequestMapping("/edu/like")
@Api(tags = "点赞表")
public class LikeContentController {

    @Autowired
    private LikeContentService likeService;

    //点赞表-用户点赞内容
    @ApiOperation("点赞表-用户点赞内容")
    @PostMapping("likeContent")
    public Result<?> likeContent(@RequestBody Map<String, String> map) {
        String userId = map.get("userId");
        String columnType = map.get("columnType");
        String contentId = map.get("contentId");
        String authorId = map.get("authorId");
        Result<?> result = likeService.likeContent(contentId, userId, columnType,authorId);
        return result;
    }

    //点赞表-用户取消点赞内容
    @ApiOperation("点赞表-用户取消点赞内容")
    @PostMapping("dislikeContent")
    public Result<?> dislikeContent(@RequestBody Map<String, String> map) {
        String userId = map.get("userId");
        String columnType = map.get("columnType");
        String columnId = map.get("contentId");
        Result<?> result = likeService.dislikeContent(columnId, userId, columnType);
        return result;
    }

    //点赞表-获取我的点赞列表
    @ApiOperation("点赞表-获取我的点赞列表")
    @PostMapping("likeList")
    public Result<?> likeList(@RequestBody Map<String, String> map) {
        String userId = map.get("userId");
        String columnType = map.get("columnType");
        Result<?> result = likeService.likeList(userId, columnType);
        return result;
    }

    //点赞表-获取我的获赞列表
    @ApiOperation("点赞表-获取我的获赞列表")
    @GetMapping("likedUserList/{userId}")
    public Result<List<MyLikedVo>> likedUserList(@PathVariable String userId) {
        Result<List<MyLikedVo>> result = likeService.likedUserList(userId);
        return result;
    }

    //得到该作者的昨天的点赞量
    @ApiOperation("得到该作者的昨天的点赞量")
    @GetMapping("getLastLikeCount/{userId}")
    public Result<Map<String, Long>> getLastLikeCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = likeService.getLastLikeCount(userId);
        return result;
    }

    //得到该作者的一周的点赞量
    @ApiOperation("得到该作者的一周的点赞量")
    @GetMapping("getWeekLikeCount/{userId}")
    public Result<Map<String, Long>> getWeekLikeCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = likeService.getWeekLikeCount(userId);
        return result;
    }

    //得到该作者的一月的点赞量
    @ApiOperation("得到该作者的一月的点赞量")
    @GetMapping("getMonthCount/{userId}")
    public Result<Map<String, Long>> getMonthCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = likeService.getMonthCount(userId);
        return result;
    }

}

